package iface;

import java.io.Serializable;

/**
 * Contains messages used to send between client and server.
 * 
 * @author Jeff
 * 
 */
public class Envelope implements Serializable {
    private static final long serialVersionUID = 3L;
    private String fromUsername;
    private Message contents;

    /**
     * Constructs a new Envelope object
     * 
     * @param username
     *            the user who sent this Envelope
     * @param msg
     *            the Message contained in the Envelope
     */
    public Envelope(String username, Message msg) {
        this.contents = msg;
        this.fromUsername = username;
    }

    /**
     * @return the user who sent the Envelope
     */
    public String whoSentThis() {
        return this.fromUsername;
    }

    /**
     * @return the contents of this Envelope
     */
    public Message getContents() {
        return contents;
    }

    /**
     * Returns a String of the contents of this Envelope with format <
     * contents.toString() >
     */
    public String toString() {
        return "<" + contents.toString() + ">";
    }
}
